package com.demo;

import com.wanghaicheng.util.WordUtil;
import org.apache.poi.xwpf.usermodel.XWPFDocument;

import java.io.FileOutputStream;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class WordDemo {
    public static void main(String[] args) throws IOException {
        XWPFDocument document = WordUtil.loadDocumentFromFile("C:\\Users\\Admin\\Desktop\\wordUtil测试.docx");
        WordUtil.replacePlaceholder(document, "${name}", "文档操作工具");
        WordUtil.replacePlaceholder(document, "${time}", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        document.write(new FileOutputStream("C:\\Users\\Admin\\Desktop\\wordUtil测试1.docx"));
    }
}
